package com.briup.app01.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.app01.bean.Article;
import com.briup.app01.service.ArticleService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/article")
@Api(description = "Articlel栏目管理")
public class ArticleController {

	@Autowired
	private ArticleService articleService;

	// 保存一个或者修改一个
	@RequestMapping("/save")
	@ApiOperation(value="有id为修改，反之为保存")
	public String save(Article article) {
		articleService.saveOrupdate(article);
		return "保存成功";
	}

	// 删除一个
	@RequestMapping("/deleteById")
	@ApiOperation("删除一个信息")
	public String deleteById(long id) {
		articleService.deleteById(id);
		return "删除成功";
	}

	// 查询所有
	@RequestMapping("/findAll")
	@ApiOperation("查询所有栏目")
	public List<Article> findAll() {
		return articleService.findAll();
	}

	// 查询单个
	@RequestMapping("/findById")
	@ApiImplicitParam(name = "id", value = "栏目id", required = true)
	@ApiOperation("根据id查询一个信息")
	public Article findById(long id) {
		return articleService.selectById(id);

	}

}
